<?php

use yii\db\Migration;

/**
 * Handles the creation of table `{{%admin_user}}`.
 */
class m200423_071633_create_admin_user_table extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $this->createTable('{{%admin_user}}', [
            'id' => $this->primaryKey()->comment('主键ID'),
            'username' => $this->string(255)->notNull()->comment('用户名'),
            'nickname' => $this->string(255)->notNull()->defaultValue('')->comment('昵称'),
            'auth_key' => $this->string(32)->notNull()->defaultValue('')->comment('auth_key'),
            'password_hash' => $this->string(180)->notNull()->defaultValue('')->comment('password_hash'),
            'password_reset_token' => $this->string(180)->notNull()->defaultValue('')->comment('password_reset_token'),
            'status' => $this->tinyInteger(3)->notNull()->unsigned()->defaultValue(0)->comment('状态0:正常,1禁止登陆'),
            'last_login' => $this->dateTime()->comment('最后登陆时间'),
            'create_time' => $this->dateTime()->notNull()->comment('创建时间'),
            'update_time' => $this->dateTime()->notNull()->comment('更新时间')
        ]);
        $this->addCommentOnTable("{{%admin_user}}", '后台管理员表');
    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        $this->dropTable('{{%admin_user}}');
    }
}
